package org.jeecg.modules.rooms.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.rooms.entity.CesAllDayRuleMinute;
import org.jeecg.modules.rooms.mapper.CesAllDayRuleMinuteMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 全天房第2点按分钟收费按房型设置表 服务实现类
 * </p>
 *
 * @author Claude
 * @since 2023-03-07
 */
@Service
public class CesAllDayRuleMinuteServiceImpl extends ServiceImpl<CesAllDayRuleMinuteMapper, CesAllDayRuleMinute> implements IService<CesAllDayRuleMinute> {


    @Resource
    private CesAllDayRuleMinuteMapper cesAllDayRuleMinuteMapper;

    /**
     * 根据酒店id 查询当前酒店全天房计费 房型规则
     * @param hotelId
     * @return
     */
    public List<CesAllDayRuleMinute> getRuleMinutesByHotelId(String hotelId){
        if(StringUtils.isEmpty(hotelId)) return  new ArrayList<>();

       List<CesAllDayRuleMinute> data =  cesAllDayRuleMinuteMapper.selectList(Wrappers.<CesAllDayRuleMinute>lambdaQuery()
                .eq(CesAllDayRuleMinute::getHotelId,  hotelId)
                .eq(CesAllDayRuleMinute::getInvalid, false)
        );
       return  data;
    }
}
